//
//  MyOrderStateTableViewCell.m
//  customer
//
//  Created by Holothurian on 2018/10/30.
//  Copyright © 2018年 yinlong. All rights reserved.
//

#import "MyOrderStateTableViewCell.h"

@interface MyOrderStateTableViewCell()

@property (nonatomic,strong)UIImageView *sunImgView;

/**
 服务需求
 */
@property (nonatomic,strong)UILabel *demondLabel;

/**
 0:已取消 1:待指派  2:待上门  3:等待确认服务  4:待付款  5:已付款
 
 */
@property (nonatomic,strong)UILabel *orderStateLabel;

/**
 卫生间区域
 */
@property (nonatomic,strong)UILabel *firstPartLabel;


/**
 马桶
 */
@property (nonatomic,strong)UILabel *secondPartLabel;

/**
 详情区域
 */
@property (nonatomic,strong)UILabel *thirdPartLabel;

/**
 服务时间：
 */
@property (nonatomic,strong)UILabel *serviceTimeLabel;

/**
 服务地址
 */
@property (nonatomic,strong)UILabel *serviceAddressLabel;

/**
 取消订单、删除订单
 */
@property (nonatomic,strong)UIButton *cancelButton;

/**
 查看详情、立即支付、立即评价
 */
@property (nonatomic,strong)UIButton *detailButton;

@end

@implementation MyOrderStateTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        AutoWeakSelf
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _sunImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"serviceDemand"]];
        _sunImgView.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:_sunImgView];
        [_sunImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).offset(10);
            make.top.equalTo(weakSelf.contentView).offset(18);
            make.size.mas_equalTo(CGSizeMake(15, 15));
        }];
        
        _demondLabel = [[UILabel alloc]init];
        _demondLabel.text = @"服务需求";
        _demondLabel.font = Font(15);
        _demondLabel.textColor = [HSPublic colorWithHexString:@"#808080"];
        [self.contentView addSubview:_demondLabel];
        [_demondLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.sunImgView.mas_right).offset(10);
            make.top.equalTo(weakSelf.contentView).offset(10);
            make.size.mas_equalTo(CGSizeMake(100, 30));
        }];
        
        _orderStateLabel = [[UILabel alloc]init];
        _orderStateLabel.textColor = [HSPublic colorWithHexString:@"#DD2727"];
        _orderStateLabel.font = Font(12);
        _orderStateLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_orderStateLabel];
        [_orderStateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(weakSelf.contentView).offset(-15);
            make.top.mas_equalTo(weakSelf.contentView).offset(10);
            make.size.mas_equalTo(CGSizeMake(120, 30));
        }];
        
        _firstPartLabel = [[UILabel alloc]init];
        _firstPartLabel.textColor = [HSPublic colorWithHexString:@"#1F89FF"];
        _firstPartLabel.textAlignment = NSTextAlignmentCenter;
        _firstPartLabel.font = Font(12);
        _firstPartLabel.layer.borderColor = [HSPublic colorWithHexString:@"1F89FF"].CGColor;
        _firstPartLabel.layer.borderWidth = 1;
        _firstPartLabel.layer.cornerRadius = 3;
        _firstPartLabel.layer.masksToBounds = YES;
        [self.contentView addSubview:_firstPartLabel];
        [_firstPartLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(weakSelf.contentView).offset(10);
            make.top.mas_equalTo(weakSelf.demondLabel.mas_bottom).offset(10);
            make.height.mas_equalTo(30);
            make.width.mas_equalTo(60);
        }];
        
        _secondPartLabel = [[UILabel alloc]init];
        _secondPartLabel.textColor = [HSPublic colorWithHexString:@"#1F89FF"];
        _secondPartLabel.textAlignment = NSTextAlignmentCenter;
        _secondPartLabel.font = Font(12);
        _secondPartLabel.layer.borderColor = [HSPublic colorWithHexString:@"1F89FF"].CGColor;
        _secondPartLabel.layer.borderWidth = 1;
        _secondPartLabel.layer.cornerRadius = 3;
        _secondPartLabel.layer.masksToBounds = YES;
        [self.contentView addSubview:_secondPartLabel];
        [_secondPartLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(weakSelf.firstPartLabel.mas_right).offset(10);
            make.top.mas_equalTo(weakSelf.demondLabel.mas_bottom).offset(10);
            make.height.mas_equalTo(30);
            make.width.mas_equalTo(60);
        }];
        
        _thirdPartLabel = [[UILabel alloc]init];
        _thirdPartLabel.textColor = [HSPublic colorWithHexString:@"#1F89FF"];
        _thirdPartLabel.textAlignment = NSTextAlignmentCenter;
        _thirdPartLabel.font = Font(12);
        _thirdPartLabel.layer.borderColor = [HSPublic colorWithHexString:@"1F89FF"].CGColor;
        _thirdPartLabel.layer.borderWidth = 1;
        _thirdPartLabel.layer.cornerRadius = 3;
        _thirdPartLabel.layer.masksToBounds = YES;
        _thirdPartLabel.hidden = YES;
        [self.contentView addSubview:_thirdPartLabel];
        [_thirdPartLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(weakSelf.secondPartLabel.mas_right).offset(10);
            make.top.mas_equalTo(weakSelf.demondLabel.mas_bottom).offset(10);
            make.right.mas_equalTo(weakSelf.contentView).offset(-15);
            make.height.mas_equalTo(30);
            
        }];
        UIView *serviceView = [[UIView alloc]init];
        serviceView.backgroundColor = [HSPublic colorWithHexString:@"#F5F5F5"];
        [self.contentView addSubview:serviceView];
        [serviceView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.firstPartLabel.mas_bottom).offset(10);
            make.left.right.equalTo(weakSelf.contentView).offset(0);
            make.height.mas_equalTo(60);
        }];
        
        _serviceTimeLabel = [[UILabel alloc]init];
        _serviceTimeLabel.text = @"服务时间：";
        _serviceTimeLabel.textColor = [UIColor blackColor];
        _serviceTimeLabel.font = Font30;
        [serviceView addSubview:_serviceTimeLabel];
        [_serviceTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(serviceView).offset(10);
            make.top.mas_equalTo(serviceView);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 20, 29));
        }];
        
        UIView *lineView = [[UIView alloc]init];
        lineView.backgroundColor = [UIColor whiteColor];
        [serviceView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(serviceView);
            make.top.equalTo(weakSelf.serviceTimeLabel.mas_bottom).offset(0);
            make.height.mas_equalTo(1);
        }];
        _serviceAddressLabel = [[UILabel alloc]init];
        _serviceAddressLabel.text = @"服务地址：";
        _serviceAddressLabel.textColor = [UIColor blackColor];
        _serviceAddressLabel.font = Font30;
        [serviceView addSubview:_serviceAddressLabel];
        [_serviceAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(serviceView).offset(10);
            make.top.mas_equalTo(lineView.mas_bottom).offset(0);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 20, 30));
        }];
        
        _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _cancelButton.layer.cornerRadius = 1;
        _cancelButton.layer.borderWidth = 1;
        _cancelButton.layer.borderColor = [HSPublic colorWithHexString:@"666666"].CGColor;
        _cancelButton.layer.masksToBounds = YES;
        _cancelButton.titleLabel.font = Font(12);
        [_cancelButton setTitle:@"取消订单" forState:UIControlStateNormal];
        [_cancelButton setTitle:@"取消订单" forState:UIControlStateSelected];
        [_cancelButton setTitleColor:[HSPublic colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        [_cancelButton setTitleColor:[HSPublic colorWithHexString:@"#666666"] forState:UIControlStateSelected];
        [_cancelButton addTarget:self action:@selector(cancelButtonAction) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_cancelButton];
        [_cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(weakSelf.contentView).offset(-110);
            make.top.mas_equalTo(serviceView.mas_bottom).mas_offset(10);
            make.size.mas_equalTo(CGSizeMake(80, 30));
        }];
        
        _detailButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _detailButton.layer.cornerRadius = 1;
        _detailButton.layer.borderWidth = 1;
        _detailButton.layer.borderColor = [HSPublic colorWithHexString:@"1F89FF"].CGColor;
        _detailButton.layer.masksToBounds = YES;
        _detailButton.titleLabel.font = Font(12);
        _detailButton.backgroundColor = [HSPublic colorWithHexString:@"1F89FF"];
        [_detailButton setTitle:@"查看详情" forState:UIControlStateNormal];
        [_detailButton setTitle:@"查看详情" forState:UIControlStateSelected];
        [_detailButton setTitleColor:[HSPublic colorWithHexString:@"1F89FF"] forState:UIControlStateNormal];
        [_detailButton setTitleColor:[HSPublic colorWithHexString:@"1F89FF"] forState:UIControlStateSelected];
        [_detailButton addTarget:self action:@selector(detailButtonEvent) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_detailButton];
        [_detailButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(weakSelf.contentView).offset(-15);
            make.top.mas_equalTo(serviceView.mas_bottom).mas_offset(10);
            make.size.mas_equalTo(CGSizeMake(80, 30));
        }];
    }
    return self;
}

- (void)cellForOrderLayout:(OrderBaseModel *)model{
    self.orderStateLabel.text = model.order_state_show?:@"";
    //维修区域
    [self layoutRepairParts:model];
    self.serviceTimeLabel.text = [NSString stringWithFormat:@"服务时间：%@ %@",model.service_start_time,model.service_end_time];
    self.serviceAddressLabel.text = [NSString stringWithFormat:@"服务地址：%@%@%@%@%@%@",model.maintailOrderAddressBean.address_province,model.maintailOrderAddressBean.address_city,model.maintailOrderAddressBean.address_country,model.maintailOrderAddressBean.address_detailed,model.maintailOrderAddressBean.address_name,model.maintailOrderAddressBean.address_road];
    //状态按钮
    [self layoutStateButtonOnBottom:model];
}


- (void)layoutRepairParts:(OrderBaseModel *)model{
    NSArray *partsArr = [model.parts_names componentsSeparatedByString:@","];
    AutoWeakSelf
    if (partsArr.count == 2) {
        NSString *firstItem = partsArr.firstObject;
        NSString *secondItem = partsArr.lastObject;
        CGFloat firstItemWidth = [HSPublic hsBoundingRectWithWidthString:firstItem SizeHeight:30 Font:Font(12)];
        CGFloat secondItemWidth = [HSPublic hsBoundingRectWithWidthString:secondItem SizeHeight:30 Font:Font(12)];
        if (firstItemWidth > 60) {
            [weakSelf.firstPartLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(weakSelf.contentView).offset(10);
                make.top.mas_equalTo(weakSelf.demondLabel.mas_bottom).offset(10);
                make.height.mas_equalTo(30);
                make.width.mas_equalTo(firstItemWidth);
            }];
        }else if (secondItemWidth > 60){
            [weakSelf.secondPartLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(weakSelf.firstPartLabel.mas_right).offset(10);
                make.top.mas_equalTo(weakSelf.demondLabel.mas_bottom).offset(10);
                make.height.mas_equalTo(30);
                make.width.mas_equalTo(secondItemWidth);
            }];
        }
        self.firstPartLabel.text = firstItem?:@"";
        self.secondPartLabel.text = secondItem?:@"";
        self.thirdPartLabel.hidden = YES;
    }else if (partsArr.count == 3){
        NSString *firstItem = partsArr.firstObject;
        NSString *secondItem = partsArr[1];
        NSString *thirdItem = partsArr.lastObject;
        CGFloat firstItemWidth = [HSPublic hsBoundingRectWithWidthString:firstItem SizeHeight:30 Font:Font(12)];
        CGFloat secondItemWidth = [HSPublic hsBoundingRectWithWidthString:secondItem SizeHeight:30 Font:Font(12)];
        if (firstItemWidth > 60) {
            [weakSelf.firstPartLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(weakSelf.contentView).offset(10);
                make.top.mas_equalTo(weakSelf.demondLabel.mas_bottom).offset(10);
                make.height.mas_equalTo(30);
                make.width.mas_equalTo(firstItemWidth);
            }];
            
        }else if (secondItemWidth > 60){
            [weakSelf.secondPartLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(weakSelf.firstPartLabel.mas_right).offset(10);
                make.top.mas_equalTo(weakSelf.demondLabel.mas_bottom).offset(10);
                make.height.mas_equalTo(30);
                make.width.mas_equalTo(secondItemWidth);
            }];
        }
        self.firstPartLabel.text = firstItem?:@"";
        self.secondPartLabel.text = secondItem?:@"";
        self.thirdPartLabel.text = thirdItem?:@"";
        self.thirdPartLabel.hidden = NO;
    }
}


/**
 布局底部的两个button
 自定义上tag值、传值操作更方便、
 //取消订单、查看详情、立即确认、立即支付、立即评价、删除订单
 //100、    101、   102、    103、    104、   105、
 @param model 订单Model
 */
- (void)layoutStateButtonOnBottom:(OrderBaseModel *)model{
    _cancelButton.hidden = NO;
    _detailButton.hidden = NO;
    // 0:已取消 1:待指派  2:待上门  3:等待确认服务  4:待付款  5:已付款
    if ([model.order_state isEqualToString:@"0"]) {
        _cancelButton.hidden = YES;
        _detailButton.tag = 105;
        [self changeCurrentButton:_detailButton Title:@"删除订单" TitleColor:[HSPublic colorWithHexString:@"#D51A28"] BackgroundColor:[UIColor whiteColor]];
        
    }
    else if ([model.order_state isEqualToString:@"1"]){
        // 后台指派出去 师傅接受状态  默认是接受  师傅可以拒绝  1:接受 2:拒绝
        if (![model.accept_state isEqualToString:@"2"]) {
            _cancelButton.hidden = YES;
            _detailButton.tag = 100;
            [self changeCurrentButton:_detailButton Title:@"取消订单" TitleColor:[HSPublic colorWithHexString:@"#666666"] BackgroundColor:[UIColor whiteColor]];
        }else{//拒绝后 重新指派中
            _cancelButton.hidden = YES;
            _detailButton.hidden = YES;
        }
    }
    else if ([model.order_state isEqualToString:@"2"]){
        _cancelButton.tag = 100;
        _detailButton.tag = 101;
        [self changeCurrentButton:_cancelButton Title:@"取消订单" TitleColor:[HSPublic colorWithHexString:@"#666666"] BackgroundColor:[UIColor whiteColor]];
        [self changeCurrentButton:_detailButton Title:@"查看详情" TitleColor:[UIColor whiteColor] BackgroundColor:[HSPublic colorWithHexString:@"#1F89FF"]];
    }
    else if ([model.order_state isEqualToString:@"3"]){
        _cancelButton.tag = 100;
        _detailButton.tag = 102;
        [self changeCurrentButton:_cancelButton Title:@"取消订单" TitleColor:[HSPublic colorWithHexString:@"#666666"]BackgroundColor:[UIColor whiteColor]];
        [self changeCurrentButton:_detailButton Title:@"立即确认" TitleColor:[UIColor whiteColor] BackgroundColor:[HSPublic colorWithHexString:@"#1F89FF"]];
    }
    else if ([model.order_state isEqualToString:@"4"]){
        _cancelButton.hidden = YES;
        _detailButton.tag = 103;
        [self changeCurrentButton:_detailButton Title:@"立即支付" TitleColor:[UIColor whiteColor] BackgroundColor:[HSPublic colorWithHexString:@"1F89FF"]];
    }
    else if ([model.order_state isEqualToString:@"5"]){
        //评价状态 1:未评价 2:已评价
        if ([model.assessment_state isEqualToString:@"1"]) {
            _cancelButton.tag = 105;
            _detailButton.tag = 104;
            [self changeCurrentButton:_cancelButton Title:@"删除订单" TitleColor:[HSPublic colorWithHexString:@"#D0021B"] BackgroundColor:[UIColor whiteColor]];
            [self changeCurrentButton:_detailButton Title:@"立即评价" TitleColor:[UIColor whiteColor] BackgroundColor:[HSPublic colorWithHexString:@"1F89FF"]];
        }else{
            _cancelButton.hidden = YES;
            _detailButton.tag = 105;
            [self changeCurrentButton:_detailButton Title:@"删除订单" TitleColor:[HSPublic colorWithHexString:@"#D0021B"]BackgroundColor:[UIColor whiteColor]];
            
        }
    }
}

- (void)changeCurrentButton:(UIButton *)currentButton Title:(NSString *)title TitleColor:(UIColor *)titleColor BackgroundColor:(UIColor *)backgroundColor{
    [currentButton setTitle:title?:@"" forState:UIControlStateNormal];
    [currentButton setTitle:title?:@"" forState:UIControlStateSelected];
    [currentButton setTitleColor:titleColor?:[UIColor blackColor] forState:UIControlStateNormal];
    [currentButton setTitleColor:titleColor?:[UIColor blackColor] forState:UIControlStateSelected];
    [currentButton setBackgroundColor:backgroundColor?:[UIColor whiteColor]];
    currentButton.layer.borderColor = titleColor.CGColor;
}

- (void)cancelButtonAction{
    if ([self.delegate respondsToSelector:@selector(orderStateCancelButtonIndexPath:ActionTag:)]) {
        [self.delegate orderStateCancelButtonIndexPath:self.indexPath ActionTag:_cancelButton.tag];
    }
}

- (void)detailButtonEvent{
    if ([self.delegate respondsToSelector:@selector(orderStateDetailButtonIndexPath:ActionTag:)]) {
        [self.delegate orderStateDetailButtonIndexPath:self.indexPath ActionTag:_detailButton.tag];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end


@implementation MyOrderDetailOrderStateTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        AutoWeakSelf
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [HSPublic colorWithHexString:@"#1F89FF"];
        _orderStateLabel = [[UILabel alloc]init];
        _orderStateLabel.textColor = [UIColor whiteColor];
        _orderStateLabel.font = Font(15);
        [self.contentView addSubview:_orderStateLabel];
        [_orderStateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).mas_offset(20);
            make.top.mas_equalTo(weakSelf.contentView).mas_offset(10);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 30, 30));
        }];
        
        _orderNumberLabel = [[UILabel alloc]init];
        _orderNumberLabel.textColor = [UIColor whiteColor];
        _orderNumberLabel.font = Font(12);
        [self.contentView addSubview:_orderNumberLabel];
        [_orderNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).mas_offset(20);
            make.top.mas_equalTo(weakSelf.orderStateLabel.mas_bottom).mas_offset(0);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 30, 25));
        }];
        
        _orderTimeLabel = [[UILabel alloc]init];
        _orderTimeLabel.textColor = [UIColor whiteColor];
        _orderTimeLabel.font = Font(12);
        [self.contentView addSubview:_orderTimeLabel];
        [_orderTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).mas_offset(20);
            make.top.mas_equalTo(weakSelf.orderNumberLabel.mas_bottom).mas_offset(0);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 30, 25));
        }];
    }
    return self;
}

- (void)cellForLayout:(OrderBaseModel *)orderModel{
    self.orderStateLabel.text = orderModel.order_state_show?:@"";
    self.orderNumberLabel.text = [NSString stringWithFormat:@"订单编号：%@",orderModel.order_no];
    self.orderTimeLabel.text = [NSString stringWithFormat:@"下单时间：%@",orderModel.create_time];
}

@end


@implementation MyOrderDetailAddressTableCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        AutoWeakSelf
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [HSPublic colorWithHexString:@"FDFBEF"];
        _contactNameLabel = [[UILabel alloc]init];
        _contactNameLabel.textColor = [UIColor blackColor];
        _contactNameLabel.font = Font(15);
        [self.contentView addSubview:_contactNameLabel];
        [_contactNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).mas_offset(20);
            make.top.mas_equalTo(weakSelf.contentView).mas_offset(10);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W/2.0-30, 25));
        }];
        
        _contactPhoneLabel = [[UILabel alloc]init];
        _contactPhoneLabel.textColor = [UIColor blackColor];
        _contactPhoneLabel.font = Font(15);
        [self.contentView addSubview:_contactPhoneLabel];
        [_contactPhoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf.contentView).mas_offset(-15);
            make.top.mas_equalTo(weakSelf.contentView).mas_offset(10);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W /2.0 - 30, 25));
        }];
        
        _positionImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"location_g"]];
        _positionImgView.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:_positionImgView];
        [_positionImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).offset(3);
            make.top.equalTo(weakSelf.contactNameLabel.mas_bottom).offset(15);
            make.size.mas_equalTo(CGSizeMake(13, 13));
        }];
        
        
        _serviceAddressLabel = [[UILabel alloc]init];
        _serviceAddressLabel.textColor = [UIColor blackColor];
        _serviceAddressLabel.font = Font(15);
        _serviceAddressLabel.numberOfLines = 0;
        [self.contentView addSubview:_serviceAddressLabel];
        [_serviceAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).mas_offset(20);
            make.top.mas_equalTo(weakSelf.contactNameLabel.mas_bottom).mas_offset(10);
            make.size.mas_equalTo(CGSizeMake(F_DEVICE_W - 30, 45));
        }];
    }
    return self;
}

- (void)cellForLayout:(OrderBaseModel *)orderModel{
    self.contactNameLabel.text = [NSString stringWithFormat:@"联系人：%@",orderModel.maintailOrderAddressBean.address_name?:@""];
    self.contactPhoneLabel.text = orderModel.maintailOrderAddressBean.address_mobile?:@"";
    self.serviceAddressLabel.text = [NSString stringWithFormat:@"服务地址：%@%@%@%@%@",orderModel.maintailOrderAddressBean.address_province,orderModel.maintailOrderAddressBean.address_city,orderModel.maintailOrderAddressBean.address_country,orderModel.maintailOrderAddressBean.address_detailed,orderModel.maintailOrderAddressBean.address_road];
}

@end

@implementation MyOrderDetailServicePersionTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        AutoWeakSelf
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [HSPublic colorWithHexString:@"FDFBEF"];
        _headImgView = [[UIImageView alloc]init];
        _headImgView.contentMode = UIViewContentModeScaleToFill;
        [self.contentView addSubview:_headImgView];
        [_headImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView).mas_offset(15);
            make.top.equalTo(weakSelf.contentView).offset(10);
            make.size.mas_equalTo(CGSizeMake(40, 40));
        }];
        _repairPersonLabel = [[UILabel alloc]init];
        _repairPersonLabel.textColor = [UIColor blackColor];
        _repairPersonLabel.font = Font(18);
        [self.contentView addSubview:_repairPersonLabel];
        [_repairPersonLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.headImgView.mas_right).mas_offset(20);
            make.top.equalTo(weakSelf.contentView).mas_offset(10);
            make.size.mas_equalTo(CGSizeMake(80, 25));
        }];
        
        _starView = [[HSStarView alloc]initWithFrame:CGRectMake(160, 10, 80, 20) numberOfStars:5];
        _starView.allowIncompleteStar = YES;
        _starView.hasAnimation = YES;
        [self.contentView addSubview:_starView];

        _contactRepairsButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_contactRepairsButton setTitle:@"联系师傅" forState:UIControlStateNormal];
        [_contactRepairsButton setTitle:@"联系师傅" forState:UIControlStateSelected];
        _contactRepairsButton.titleLabel.font = Font(12);
        [_contactRepairsButton setTitleColor:[HSPublic colorWithHexString:@"666666"] forState:UIControlStateNormal];
        [_contactRepairsButton setTitleColor:[HSPublic colorWithHexString:@"666666"] forState:UIControlStateSelected];
        [_contactRepairsButton setImage:[UIImage imageNamed:@"orderDetailContact"] forState:UIControlStateNormal];
        [_contactRepairsButton setImage:[UIImage imageNamed:@"orderDetailContact"] forState:UIControlStateSelected];
        [_contactRepairsButton setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 0)];
        [self.contentView addSubview:_contactRepairsButton];
        [_contactRepairsButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(weakSelf.contentView);
            make.right.equalTo(weakSelf.contentView).mas_offset(-10);
            make.size.mas_equalTo(CGSizeMake(70, 30));
        }];
        
        _repairPhoneLabel = [[UILabel alloc]init];
        _repairPhoneLabel.textColor = [HSPublic colorWithHexString:@"666666"];
        _repairPhoneLabel.font = Font(15);
        [self.contentView addSubview:_repairPhoneLabel];
        [_repairPhoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.headImgView.mas_right).offset(20);
            make.top.equalTo(weakSelf.repairPersonLabel.mas_bottom).offset(3);
            make.size.mas_equalTo(CGSizeMake(120, 20));
        }];
    }
    return self;
}


- (void)cellForLayout:(OrderDetailModel *)orderModel{
    if (orderModel) {
        [self.headImgView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kCustomerImageIP,orderModel.workerBean.member_img?:@""]] placeholderImage:[UIImage imageNamed:@"globalPlaceholder"]];
        self.repairPersonLabel.text = orderModel.workerBean.member_real_name?:@"";
        self.repairPhoneLabel.text = orderModel.workerBean.member_account?:@"";
        self.starView.scorePercent = [orderModel.workerBean.assessment_star floatValue];
    }
}


@end
